home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9472 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.5 KB

  1. Path: keats.ugrad.cs.ubc.ca!not-for-mail
  2. From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Segmentation Fault ???
  5. Date: 10 Mar 1996 10:31:15 -0800
  6. Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
  7. Message-ID: <4hv75jINNpss@keats.ugrad.cs.ubc.ca>
  8. References: <4hsa7i$en3@wraith.its.uow.edu.au> <4huis1$cm2@ccshst05.cs.uoguelph.ca>
  9. NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
  10.  
  11. In article <4huis1$cm2@ccshst05.cs.uoguelph.ca>,
  12. Toby K Hay <thay@uoguelph.ca> wrote:
  13.  >Theeradech Paopeng (tp02@wraith.its.uow.edu.au) wrote:
  14.  >: Hello to all.
  15.  >:     I'm here to ask you guys about the "Segmentation Fault". 
  16.  >: I was run my program on Unix and I got run_time_error say that "Segmentation
  17.  >: Fault". I really no idea how to fix that problem. One more thing I have to tell to fix that problem. One more thing I have to tell
  18.  >
  19.  >This is a coincidence.  I moved a running ANSI C program from Turbo C on 
  20.  >my PC to a multi-processor Silicon Graphics UNIX machine yesterday (my 
  21.  >first try at running C on anything but a PC) and got the same error.  
  22.  >Retrying invoked a "Bus Error".  I assumed that my abysmal ingnorance of 
  23.  >UNIX was causing me to omit essential switches from the command line or 
  24.  >something of that nature, and resolved to ask on an SGI newsgroup, and to 
  25.  >ask the system administrator for guidance after the weekend.  
  26.  >This is all off topic for this group but, seeing the title, I couldn't 
  27.  >resist describing my difficulties too.
  28.  
  29. It means that you are making errors in your code that the Turbo C environment
  30. doesn't catch. The bus error is likely caused by invoking
  31. implementation-specific behavior that is in contravention to standard C:
  32. converting a pointer to one that has a stricter alignment. On many of the
  33. processors used in UNIX workstations, the address of a long word has to be
  34. divisible by four. On a 68000 processor, the address of a 16-bit word has to be
  35. divisible by two.
  36.  
  37. If you fail to meet these alignment restrictions, the hardware will trigger an
  38. exception, and the UNIX kernel will send a SIGBUS signal to your program.
  39.  
  40. The SIGBUS signal can also be generated by accesses to certain kinds of virtual
  41. memory pages, and can be artifically triggered using the raise() function,
  42. though I doubt that either of these scenarios is the case in your program.
  43.  
  44. A ``segmentation fault'', (SIGSEGV signal), on the other hand, is caused by
  45. accessing illegal memory, such as dereferencing a null pointer, reaching past
  46. the limits of your malloc heap or stack and so forth.
  47.  
  48.  
  49.  
  50. -- 
  51.  
  52.